package com.avocado.bt.impl.condition;

import com.avocado.bt.BTState;
import com.avocado.bt.IBTContext;
import com.avocado.bt.abs.condition.ConditionNode;

import java.util.Random;

/**
 * 检测区域是否有敌人
 *
 * @Author: zsh
 * @Date: 2023/10/17 11:15
 */
public class CheckAreaConditionNode extends ConditionNode {

    public CheckAreaConditionNode(String param) {
        super(param);
    }

    @Override
    public BTState doUpdate(IBTContext context) {
        Random random = new Random();
        int num = random.nextInt(100);
        if (num % 2 == 0) {
            // 有敌人
            System.out.println("发现敌人");
            return BTState.Completed;
        }
        System.out.println("未发现敌人");
        return BTState.Failure;
    }

}
